#include "common.h"

vector<vector<int>> ans;
int flgs[6] = { 0 };
void dfs(vector<int>& nums, vector<int> arr, int n)
{
	for (int i = 0; i < nums.size(); i++)
	{
		if (flgs[i] == 0)
		{
			arr.push_back(nums[i]);
			n--;
			if (n == 0)
			{
				ans.push_back(arr);
			}
			flgs[i] = 1;
			dfs(nums, arr, n);
			arr.pop_back();
			flgs[i] = 0;
			n++;
		}
	}
}
vector<vector<int>> permute(vector<int>& nums)
{
	vector<int> temp;
	dfs(nums, temp, nums.size());
	return ans;
}